﻿@model BussinessLogic.Models.QuestionnaireDaily
@{
    ViewBag.Title = "DailyQuestionnaire";
    string questionId;
    string answerId;
    string aListId;
}
<h2>
    DailyQuestionnaire</h2>
@using (Html.BeginForm())
{
    <fieldset>
        <legend>@Model.Name</legend>
        <p>@Model.Description</p>
        <ol id="qList">
            @foreach (var question in Model.Questions.OrderBy(q => q.Position))
            {
                questionId = string.Format("question_{0}_{1}_{2}", question.ID, question.HasFreeAnswer ? 1 : 0, question.HasMultipleChoice ? 1 : 0);
                <li id="@questionId">
                    <p>@question.Text</p>
                    @if (!question.HasFreeAnswer)
                    {
                        aListId = "aList" + question.ID;
                        <ul id="@aListId">
                            @foreach (var answer in question.Answers)
                            {
                                answerId = "answer" + answer.ID;
                                <li style="list-style: none">
                                    @if (question.HasMultipleChoice)
                                    {
                                        @Html.CheckBox(answerId, false)
                                    }
                                    else
                                    {
                                        @Html.RadioButton(aListId, answerId)
                                    }
                                    @Html.Label(answerId, answer.Text)
                                </li>
                            }
                        </ul>
                    }
                    else
                    {
                        @Html.TextBox("qAnswer", string.Empty, new { style = "width:450px" })
                    }
                </li>
            }
        </ol>
    </fieldset>

    <input id="jsonResult" type="text" name="jsonResult" />
    <input type="submit" name="Save" value="Save" />
}
<script src="../../Scripts/Questionnaire/DailyQuestionnaire.js" type="text/javascript"></script>
